package com.item.controller;


import com.item.domain.TbUserVisitor;
import com.item.po.TbUserVisitorPo;
import com.item.service.TbUserVisitorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TbUserVisitorController {

    @Autowired
    TbUserVisitorsService tbUserVisitorService;

    @PostMapping(value = "/tbUserVisitor/{limit}/{page}")
    public List<TbUserVisitorPo> TbUserVisitor(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) TbUserVisitor tbUserVisitor) {
        List<TbUserVisitorPo> tbUserVisitors = tbUserVisitorService.findAll(limit, page, tbUserVisitor);
        return tbUserVisitors;
    }

    @PostMapping(value = "/tbUserVisitor/add")
    public Integer TbUserVisitorAdd(@RequestBody TbUserVisitor tbUserVisitor) {
        tbUserVisitor.setDflag(0);
        int i = tbUserVisitorService.add(tbUserVisitor);
        return i;
    }

    @PutMapping(value = "/tbUserVisitor/update")
    public Integer tbUserVisitorUpdate(@RequestBody TbUserVisitor tbUserVisitor) {

        int i = tbUserVisitorService.update(tbUserVisitor);
        return i;
    }

    @DeleteMapping(value = "/tbUserVisitor/{id}")
    public Integer tbUserVisitorDelete(@PathVariable(value = "id") int id) {

        int i = tbUserVisitorService.delete(id);
        return i;
    }

}
